package sealte.port.scanner.frame;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class MainFrame extends JFrame{

	private static final long serialVersionUID = 1L;
	private JPanel jp_north = null;
	private JPanel jp_center = null;
	private JLabel jl_ip = null;
	private JLabel jl_portRange = null;
	private JLabel jl_middle = null;
	private JLabel jl_maxThread = null;
	private JTextField jtf_ip = null;
	private JTextField jtf_port1 = null;
	private JTextField jtf_port2 = null;
	private JTextField jtf_maxThread = null;
	private JButton jb_scan = null;
	private JTextArea jta_content = null;
	private JScrollPane jsp_content = null;
	
	
	public MainFrame(){
		super("MyPortScanner by SEALTE v0.1");
		mfInit();
	}
	
	private void mfInit(){
		jp_north = new JPanel(new FlowLayout());
		jl_ip = new JLabel("IPv4:");
		jtf_ip = new JTextField(12);
		jl_portRange = new JLabel("Port Range:");
		jtf_port1 = new JTextField(4);
		jl_middle = new JLabel("-");
		jtf_port2 = new JTextField(4);
		jl_maxThread = new JLabel("MaxThreads:");
		jtf_maxThread = new JTextField(4);
		jb_scan = new JButton("Scan");
		jp_north.add(jl_ip);
		jp_north.add(jtf_ip);
		jp_north.add(jl_portRange);
		jp_north.add(jtf_port1);
		jp_north.add(jl_middle);
		jp_north.add(jtf_port2);
		jp_north.add(jl_maxThread);
		jp_north.add(jtf_maxThread);
		jp_north.add(jb_scan);
		this.add(jp_north,"North");
		jp_center = new JPanel(new BorderLayout());
		jta_content = new JTextArea(20,10);
		jsp_content = new JScrollPane(jta_content);
		jp_center.add(jsp_content,BorderLayout.CENTER);
		this.add(jp_center,"Center");
		this.pack();
		this.setLocation(450, 200);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public JTextField getJtf_ip() {
		return jtf_ip;
	}

	public JTextField getJtf_port1() {
		return jtf_port1;
	}

	public JTextField getJtf_port2() {
		return jtf_port2;
	}
	
	public JTextField getJtf_maxThread(){
		return jtf_maxThread;
	}
	
	public JButton getJb_scan() {
		return jb_scan;
	}

	public synchronized JTextArea getJta_content() {
		return jta_content;
	}
	
}
